//
//  QuickEditRemarkViewModel.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 10.05.25.
//

import Foundation
class QuickEditRemarkViewModel : KoiAccountingBaseViewModel {
    
    @Published var detail: AccountingDetailCombine
    
    @Published var updateState: String = ""
    
    private var detailDao = KoiAccountingDB.standard.getDetailDao()
    
    init(detail: AccountingDetailCombine) {
        self.detail = detail
    }
    
    func updateRemark(_ remark: String) {
        var detail = detail.detail
        
        asyncBackground {
            detail.remark = remark
            self.detailDao.updateRecord(detail: detail)
            self.asyncMain {
                self.updateState = "success"
            }
        }
    }
}
